fbuilderjQuery=(typeof fbuilderjQuery!='undefined') ? fbuilderjQuery:jQuery; fbuilderjQuery(function(){ (function($){ $.fbuilder=$.fbuilder||{}; $.fbuilder[ 'objName' ]='fbuilderjQuery'; $.fbuilder[ 'controls' ]=(typeof $.fbuilder[ 'controls' ]!='undefined') ? $.fbuilder[ 'controls' ]: {}; $.fbuilder[ 'forms' ]=(typeof $.fbuilder[ 'forms' ]!='undefined') ? $.fbuilder[ 'forms' ]: {}; $.fbuilder[ 'htmlEncode' ]=function(value){ value=$('
').text(value).html() value=value.replace(/&/g, '&').replace(/"/g, """); return value; }; $.fbuilder['htmlDecode']=function(value){ if(/&(?:#x[a-f0-9]+|#[0-9]+|[a-z0-9]+);?/ig.test(value))value=$('
').html(value).text();return value; }; $.fbuilder[ 'escape_symbol' ]=function(value){ return value.replace(/([\^\$\-\.\,\[\]\(\)\/\\\*\?\+\!\{\}])/g, "\\$1"); }; $.fbuilder[ 'parseValStr' ]=function(value){ return '"' + value.replace(/'/g, "\\'").replace(/\$/g, '') + '"'; }; $.fbuilder[ 'parseVal' ]=function(value, thousandSeparator, decimalSymbol){ if(value=='') return 0; value +=''; thousandSeparator=new RegExp($.fbuilder.escape_symbol(( typeof thousandSeparator=='undefined') ? ',':thousandSeparator), 'g'); decimalSymbol=new RegExp($.fbuilder.escape_symbol(( typeof decimalSymbol=='undefined') ? '.':decimalSymbol), 'g'); var t=value.replace(thousandSeparator, '').replace(decimalSymbol, '.').replace(/\s/g, ''), p=/[+-]?((\d+(\.\d+)?)|(\.\d+))/.exec(t); return(p) ? p[0]*1:$.fbuilder[ 'parseValStr' ](value); }; $.fn.fbuilder=function(options){ var opt=$.extend({}, { pub:false, identifier:"", title:"" },options, true); opt.messages=$.extend({ previous: "Previous", next: "Next", pageof: "Page {0} of {0}", required: "This field is required.", email: "Please enter a valid email address.", datemmddyyyy: "Please enter a valid date with this format(mm/dd/yyyy)", dateddmmyyyy: "Please enter a valid date with this format(dd/mm/yyyy)", number: "Please enter a valid number.", digits: "Please enter only digits.", maxlength: $.validator.format("Please enter no more than {0} characters"), minlength: $.validator.format("Please enter at least {0} characters."), equalTo: "Please enter the same value again.", max: $.validator.format("Please enter a value less than or equal to {0}."), min: $.validator.format("Please enter a value greater than or equal to {0}.") },opt.messages); opt.messages.max=$.validator.format(opt.messages.max); opt.messages.min=$.validator.format(opt.messages.min); $.extend($.validator.messages, opt.messages); var items=[]; var reloadItemsPublic=function(){ $("#fieldlist"+opt.identifier).closest('form').addClass(theForm.formtemplate); $("#fieldlist"+opt.identifier).html("").addClass(theForm.formlayout); $("#formheader"+opt.identifier).html(theForm.show()); var page=0; $("#fieldlist"+opt.identifier).append('
'); for (var i=0;i
'); }else{ $("#fieldlist"+opt.identifier+" .pb"+page).append(items[i].show()); if(items[i].predefinedClick){ $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).attr("placeholder",items[i].predefined); $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).attr("value",""); } if(items[i].userhelpTooltip){ var uh=$("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).closest(".fields"); uh.find(".uh").css("display","none"); if(uh.find(".uh").text()!=""){ uh.attr("uh",uh.find(".uh").text()); }} }} if(page>0){ $("#fieldlist"+opt.identifier+" .pb"+page).addClass("pbEnd"); $("#fieldlist"+opt.identifier+" .pbreak").each(function(index){ var code=$(this).html(); var bSubmit=''; if(index==page){ if($("#cpcaptchalayer"+opt.identifier).length&&!/^\s*$/.test($("#cpcaptchalayer"+opt.identifier).html())){ code +='
'+$("#cpcaptchalayer"+opt.identifier).html()+'
'; $("#cpcaptchalayer"+opt.identifier).html(""); } if($("#cp_subbtn"+opt.identifier).html()){ bSubmit='
'+$("#cp_subbtn"+opt.identifier).html()+'
'; }} $(this).html('
'+opt.messages.pageof.replace(/\{\s*\d+\s*\}/, (index+1)).replace(/\{\s*\d+\s*\}/, (page+1))+''+code+'
'+opt.messages.previous+'
'+opt.messages.next+'
'+bSubmit+'
'); }); $('#fieldlist'+opt.identifier).find(".pbPrevious,.pbNext").bind("click", { 'identifier':opt.identifier }, function(evt){ var identifier=evt.data.identifier; if(($(this).hasClass("pbPrevious"))||(($(this).hasClass("pbNext"))&&$(this).parents("form").valid())){ var page=parseInt($(this).parents(".pbreak").attr("page")); (($(this).hasClass("pbPrevious"))?page--:page++); $("#fieldlist"+identifier+" .pbreak").css("display","none"); $("#fieldlist"+identifier+" .pbreak").find(".field").addClass("ignorepb"); $("#fieldlist"+identifier+" .pb"+page).css("display","block"); $("#fieldlist"+identifier+" .pb"+page).find(".field").removeClass("ignorepb"); if($("#fieldlist"+identifier+" .pb"+page).find(".field").length>0){ try { $("#fieldlist"+identifier+" .pb"+page).find(".field")[0].focus(); } catch(e){}} }else{ $(this).parents("form").validate().focusInvalid(); } return false; }); }else{ if($("#cpcaptchalayer"+opt.identifier).length&&!/^\s*$/.test($("#cpcaptchalayer"+opt.identifier).html())){ $("#fieldlist"+opt.identifier+" .pb"+page).append('
'+$("#cpcaptchalayer"+opt.identifier).html()+'
'); $("#cpcaptchalayer"+opt.identifier).html(""); } if($("#cp_subbtn"+opt.identifier).html()){ $("#fieldlist"+opt.identifier+" .pb"+page).append('
'+$("#cp_subbtn"+opt.identifier).html()+'
'); }} $(document).on('click', '#fbuilder .captcha img', function(){ var e=$(this); e.attr('src', e.attr('src').replace(/&\d+$/, '') + '&' + Math.floor(Math.random()*1000)); }); $('#fieldlist'+opt.identifier).find(".pbSubmit").bind("click", { 'identifier':opt.identifier }, function(evt){ $(this).closest("form").submit(); }); if(i>0){ theForm.after_show(opt.identifier); for (var i=0;i'+(this.title!=''?'

'+this.title+'

':'')+(this.description!=''?''+this.description+'':'')+'
'; }, after_show:function(id){ $('#cp_calculatedfieldsf_pform'+id).attr('data-evalequations', this.evalequations).attr('autocomplete',(( this.autocomplete) ? 'on':'off')); }}); var theForm, ffunct={ getItem: function(name){ for(var i in items){ if(items[ i ].name==name){ return items[ i ]; }} return false; }, getItems: function(){ return items; }, loadData:function(f){ var d, e=$("#"+f); this.formId=e.parents('form').attr('id'); if(d=$.parseJSON(e.val())){ if(d.length==2){ items=[]; for (var i=0;i
'+this.userhelp+'
'; }} ); $.fbuilder.controls[ 'fcurrency' ]=function(){}; $.extend($.fbuilder.controls[ 'fcurrency' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Currency", ftype:"fcurrency", predefined:"", predefinedClick:false, required:false, size:"small", readonly:false, currencyText:"USD", thousandSeparator:",", centSeparator:".", min:"", max:"", formatDynamically:false, getFormattedValue:function(value){ this.centSeparator=$.trim(this.centSeparator); if(/^\s*$/.test(this.centSeparator)){ this.centSeparator='.'; } var v=$.trim(value); v=v.replace(new RegExp($.fbuilder[ 'escape_symbol' ](this.currencySymbol), 'g'), '') .replace(new RegExp($.fbuilder[ 'escape_symbol' ](this.currencyText), 'g'), ''); v=$.fbuilder.parseVal(v, this.thousandSeparator, this.centSeparator); if(!isNaN(v)){ v=v.toString(); var parts=v.toString().split("."), counter=0, str=''; if(!/^\s*$/.test(this.thousandSeparator)){ for(var i=parts[0].length-1; i >=0; i--){ counter++; str=parts[0][i] + str; if(counter%3==0&&i!=0) str=this.thousandSeparator + str; } parts[0]=str; } if(typeof parts[ 1 ]!='undefined'&&parts[ 1 ].length==1){ parts[ 1 ] +='0'; } if(/^\s*$/.test(this.centSeparator)){ this.centSeparator='.'; } return this.currencySymbol+parts.join(this.centSeparator)+this.currencyText; }else{ return value; }}, show:function(){ return '
'+this.userhelp+'
'; }, after_show:function(){ if(this.formatDynamically){ var me=this; $(document).on('change', '[name="' + me.name + '"]', function(){ this.value=me.getFormattedValue(this.value); }); } if(typeof $[ 'validator' ]!='undefined'){ $.validator.addMethod('min', function(value, element, param){ var e=element; if(element.id.match(/_\d+$/)){ var e=$.fbuilder[ 'forms' ][ element.id.match(/_\d+$/)[ 0 ] ].getItem(element.name) } var thousandSeparator=(typeof e.thousandSeparator!='undefined') ? e.thousandSeparator:'', centSymbol=(typeof e.centSeparator!='undefined'&&$.trim(e.centSeparator)) ? e.centSeparator:'.'; return this.optional(element)||$.fbuilder.parseVal(value, thousandSeparator, centSymbol) >=param; } ); $.validator.addMethod('max', function(value, element, param){ var e=element; if(element.id.match(/_\d+$/)){ var e=$.fbuilder[ 'forms' ][ element.id.match(/_\d+$/)[ 0 ] ].getItem(element.name) } var thousandSeparator=(typeof e.thousandSeparator!='undefined') ? e.thousandSeparator:'', centSymbol=(typeof e.centSeparator!='undefined'&&$.trim(e.centSeparator)) ? e.centSeparator:'.'; return this.optional(element)||$.fbuilder.parseVal(value, thousandSeparator, centSymbol) <=param; } ); }}, val:function(){ var e=$('[id="' + this.name + '"]:not(.ignore)'); if(e.length){ var v=$.trim(e.val()); v=v.replace(new RegExp($.fbuilder[ 'escape_symbol' ](this.currencySymbol), 'g'), '') .replace(new RegExp($.fbuilder[ 'escape_symbol' ](this.currencyText), 'g'), ''); return $.fbuilder.parseVal(v, this.thousandSeparator, this.centSeparator); } return 0; }} ); $.fbuilder.controls[ 'fnumber' ]=function(){}; $.extend($.fbuilder.controls[ 'fnumber' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Number", ftype:"fnumber", predefined:"", predefinedClick:false, required:false, size:"small", thousandSeparator:"", decimalSymbol:".", min:"", max:"", dformat:"digits", formats:new Array("digits","number"), show:function(){ return '
'+this.userhelp+'
'; }, after_show:function(){ if(typeof $[ 'validator' ]!='undefined'){ $.validator.addMethod('number', function(value, element){ var e=element; if(element.id.match(/_\d+$/)){ var e=$.fbuilder[ 'forms' ][ element.id.match(/_\d+$/)[ 0 ] ].getItem(element.name) } var thousandSeparator=(typeof e.thousandSeparator!='undefined') ? e.thousandSeparator:'', decimalSymbol=(typeof e.decimalSymbol!='undefined'&&$.trim(e.decimalSymbol)) ? e.decimalSymbol:'.'; var regExp=new RegExp('^-?(?:\\d+|\\d{1,3}(?:' + $.fbuilder.escape_symbol(thousandSeparator) + '\\d{3})+)?(?:' + $.fbuilder.escape_symbol(decimalSymbol) + '\\d+)?$'); return this.optional(element)||regExp.test(value); } ); $.validator.addMethod('min', function(value, element, param){ var e=element; if(element.id.match(/_\d+$/)){ var e=$.fbuilder[ 'forms' ][ element.id.match(/_\d+$/)[ 0 ] ].getItem(element.name) } var thousandSeparator=(typeof e.thousandSeparator!='undefined') ? e.thousandSeparator:'', decimalSymbol=(typeof e.decimalSymbol!='undefined'&&$.trim(e.decimalSymbol)) ? e.decimalSymbol:'.'; return this.optional(element)||$.fbuilder.parseVal(value, thousandSeparator, decimalSymbol) >=param; } ); $.validator.addMethod('max', function(value, element, param){ var e=element; if(element.id.match(/_\d+$/)){ var e=$.fbuilder[ 'forms' ][ element.id.match(/_\d+$/)[ 0 ] ].getItem(element.name) } var thousandSeparator=(typeof e.thousandSeparator!='undefined') ? e.thousandSeparator:'', decimalSymbol=(typeof e.decimalSymbol!='undefined'&&$.trim(e.decimalSymbol)) ? e.decimalSymbol:'.'; return this.optional(element)||$.fbuilder.parseVal(value, thousandSeparator, decimalSymbol) <=param; } ); }}, val:function(){ var e=$('[id="' + this.name + '"]:not(.ignore)'); if(e.length){ var v=$.trim(e.val()); return $.fbuilder.parseVal(v, this.thousandSeparator, this.decimalSymbol); } return 0; }} ); $.fbuilder.controls[ 'femail' ]=function(){}; $.extend($.fbuilder.controls[ 'femail' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Email", ftype:"femail", predefined:"", predefinedClick:false, required:false, size:"medium", equalTo:"", show:function(){ return '
'+this.userhelp+'
'; }, val:function(){ var e=$('[id="' + this.name + '"]:not(.ignore)'); if(e.length) return $.fbuilder.parseValStr(e.val()); return ''; }} ); $.fbuilder.controls[ 'fdate' ]=function(){}; $.extend($.fbuilder.controls[ 'fdate' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Date", ftype:"fdate", predefined:"", predefinedClick:false, size:"medium", required:false, dformat:"mm/dd/yyyy", tformat:"24", showDropdown:false, dropdownRange:"-10:+10", minDate:"", maxDate:"", invalidDates:"", minHour:0, maxHour:23, minMinute:0, maxMinute:59, stepHour: 1, stepMinute: 1, showTimepicker: false, showHM:false, defaultDate:"", defaultTime:"", working_dates:[true,true,true,true,true,true,true], formats:new Array("mm/dd/yyyy","dd/mm/yyyy"), init:function(){ function checkValue(v, min, max){ v=parseInt(v); if(isNaN(v)) v=max; else if(v < min) v=min; else if(v > max) v=max; return v; } this.minHour=checkValue(this.minHour, 0, 23); this.maxHour=checkValue(this.maxHour, 0, 23); this.minMinute=checkValue(this.minMinute, 0, 59); this.maxMinute=checkValue(this.maxMinute, 0, 59); this.stepHour=checkValue(this.stepHour, 1, Math.max(1, this.maxHour - this.minHour)); this.stepMinute=checkValue(this.stepMinute, 1, Math.max(1, this.maxMinute - this.minMinute)); this.invalidDates=this.invalidDates.replace(/\s+/g, ''); if(!/^\s*$/.test(this.invalidDates)){ var dateRegExp=new RegExp(/^\d{1,2}\/\d{1,2}\/\d{4}$/), counter=0, dates=this.invalidDates.split(','); this.invalidDates=[]; for(var i=0, h=dates.length; i < h; i++){ var range=dates[ i ].split('-'); if(range.length==2&&range[0].match(dateRegExp)!=null&&range[1].match(dateRegExp)!=null){ var fromD=new Date(range[ 0 ]), toD=new Date(range[ 1 ]); while(fromD <=toD){ this.invalidDates[ counter ]=fromD; var tmp=new Date(fromD.valueOf()); tmp.setDate(tmp.getDate() + 1); fromD=tmp; counter++; }}else{ for(var j=0, k=range.length; j < k; j++){ if(range[ j ].match(dateRegExp)!=null){ this.invalidDates[ counter ]=new Date(range[ j ]); counter++; }} }} }}, get_hours_minutes:function(){ var str='', i=0,j=0, h, from=(this.tformat==12) ? 1:this.minHour, to=(this.tformat==12) ? 12:this.maxHour; while(( h=from + this.stepHour * i) <=to){ if(h < 10) h='0'+''+h; j=0; while(( m=this.minMinute + this.stepMinute * j) <=this.maxMinute){ if(m < 10){ m='0'+''+m; } str +=''; j++; } i++; } return ''; }, get_hours:function(){ var str='', i=0, h, from=(this.tformat==12) ? 1:this.minHour, to=(this.tformat==12) ? 12:this.maxHour; while(( h=from + this.stepHour * i) <=to){ if(h < 10) h='0'+''+h; str +=''; i++; } return ':'; }, get_minutes:function(){ var str='', i=0, m; while(( m=this.minMinute + this.stepMinute * i) <=this.maxMinute){ if(m < 10){ m='0'+''+m; } str +=''; i++; } return ''; }, get_ampm:function(){ var str=''; if(this.tformat==12){ return ''; } return str; }, set_date_time:function(){ var str=$('#'+this.name+'_date').val(); if(this.showTimepicker){ if(this.showHM){ var hm=$('#'+this.name+'_hours_minutes').val().split(':'); var h=hm[0]; var m=hm[1]; }else{ var h=$('#'+this.name+'_hours').val(); var m=$('#'+this.name+'_minutes').val(); } str +=' '+(( this.tformat==12&&$('#'+this.name+'_ampm').val()=='pm') ?(h*1 + 12) % 24:h)+':'+m; } $('#'+this.name).val(str).change(); }, show:function(){ var attr='value'; if(this.predefinedClick){ attr='placeholder'; } return '
'+(( this.showTimepicker) ? ' '+((this.showHM)?this.get_hours_minutes():this.get_hours()+this.get_minutes())+' '+this.get_ampm():'')+''+this.userhelp+'
'; }, setDefaultDate:function(){ var me=this, p={ dateFormat: me.dformat.replace(/yyyy/g,"yy"), minDate: me.minDate, maxDate: me.maxDate }, dp=$("#"+me.name+"_date"), dd=(me.defaultDate!="") ? me.defaultDate:(( me.predefined!="") ? me.predefined:new Date()); dp.click(function(){ $(document).click(); $(this).focus(); }); if(me.showDropdown){ if(me.dropdownRange.indexOf(':')==-1) me.dropdownRange='-10:+10'; p=$.extend(p,{changeMonth: true,changeYear: true,yearRange: me.dropdownRange}); } p=$.extend(p, { beforeShowDay:(function(w, i){ return function(d){ return me.validateDate(d, w, i); };})(me.working_dates, me.invalidDates) }); dp.datepicker(p); if(!me.predefinedClick) dp.datepicker("setDate", dd); if(!me.validateDate(dp.datepicker("getDate"), me.working_dates, me.invalidDates)[ 0 ]){ dp.datepicker("setDate", ''); }}, setDefaultTime:function(){ function gValue(v, m){ v=Math.min(v*1, m*1); v=(v < 10) ? 0+''+v:v; return v; }; function sValue(f, v){ $('#' + f + ' [value="' + v + '"]').attr('selected', true); } if(this.showTimepicker){ var parts, time={}, tmp=0; if(( parts=/(\d{1,2}):(\d{1,2})/g.exec(this.defaultTime))!=null){ time[ 'hour' ]=parts[ 1 ]; time[ 'minute' ]=parts[ 2 ]; }else{ var d=new Date(); time[ 'hour' ]=d.getHours(); time[ 'minute' ]=d.getMinutes(); } var h=(this.tformat==12) ?(( time[ 'hour' ] > 12) ? time[ 'hour' ] - 12:(( time[ 'hour' ]==0) ? 12:time[ 'hour' ])):time[ 'hour' ]; var h1=(this.tformat==12) ? 12:this.maxHour; if(this.showHM){ sValue(this.name+'_hours_minutes', gValue(h,h1)+':'+gValue(time[ 'minute' ], this.maxMinute)); }else{ sValue(this.name+'_hours', gValue(h,h1)); sValue(this.name+'_minutes', gValue(time[ 'minute' ], this.maxMinute)); } $('#'+this.name+'_ampm'+' [value="' +(( time[ 'hour' ] < 12) ? 'am':'pm') + '"]').attr('selected', true); }}, setEvents:function(){ var me=this; $(document).on('change', '#'+this.name+'_date', function(){ me.set_date_time(); }); $(document).on('change', '#'+this.name+'_hours_minutes', function(){ me.set_date_time(); }); $(document).on('change', '#'+this.name+'_hours', function(){ me.set_date_time(); }); $(document).on('change', '#'+this.name+'_minutes', function(){ me.set_date_time(); }); $(document).on('change', '#'+this.name+'_ampm', function(){ me.set_date_time(); }); $('#cp_calculatedfieldsf_pform'+me.form_identifier).bind('reset', function(){ setTimeout(function(){ me.setDefaultDate(); me.setDefaultTime(); me.set_date_time(); }, 500); }); }, validateDate: function(d, w, i){ try{ if(d===null) return [false,""]; if(!w[ d.getDay()]) return [false,""]; if(i!==null){ for(var j=0, h=i.length; j < h; j++){ if(d.getDate()==i[ j ].getDate()&&d.getMonth()==i[ j ].getMonth()&&d.getFullYear()==i[ j ].getFullYear()) return [false,""]; }} } catch(_err){} return [true,""]; }, validateTime:function(e, i){ if(i.showTimepicker){ var base=e.name.replace('_date', ''); if(this.showHM){ var hm=$('#'+base+'_hours_minutes').val().split(':'); var h=hm[0]; var m=hm[1]; } else var h=$('#'+base+'_hours').val(), m=$('#'+base+'_minutes').val(); if(i.tformat==12){ if($('#'+base+'_ampm').val()=='pm'&&h!=12) h=h*1 + 12; if($('#'+base+'_ampm').val()=='am'&&h==12) h=0; } if(h < i.minHour||h > i.maxHour) return false; } return true; }, after_show:function(){ function closeOtherDatepicker_fdate(){ $('#ui-datepicker-div').css("display","none"); } setTimeout(closeOtherDatepicker_fdate,100); var me=this; me.setEvents(); me.setDefaultDate(); me.setDefaultTime(); $('#'+this.name+'_date').change(); var validator=function(v, e){ try { var p=e.name.replace('_date', '').split('_'), _index=(p.length > 1) ? '_'+p[ 1 ]:'', item=( typeof $.fbuilder[ 'forms' ]!='undefined' && typeof $.fbuilder[ 'forms' ][ _index ]!='undefined' ) ? $.fbuilder[ 'forms' ][ _index ].getItem(p[ 0 ]+'_'+p[ 1 ]):null, inst=$.datepicker._getInst(e), minDate=$.datepicker._determineDate(inst, $.datepicker._get(inst, 'minDate'), null), maxDate=$.datepicker._determineDate(inst, $.datepicker._get(inst, 'maxDate'), null), dateFormat=$.datepicker._get(inst, 'dateFormat'), date=$.datepicker.parseDate(dateFormat, v, $.datepicker._getFormatConfig(inst)); if(item!=null){ return this.optional(e) || ( (minDate==null||date >=minDate) && (maxDate==null||date <=maxDate) && me.validateDate($(e).datepicker('getDate'), item.working_dates, item.invalidDates)[ 0 ] && me.validateTime(e, item) ); } return true; } catch(er){ return false; }}; $.validator.addMethod("dateddmmyyyy", validator); $.validator.addMethod("datemmddyyyy", validator); }, val:function(){ var e=$('[id="' + this.name + '"]:not(.ignore)'); if(e.length){ var v=$.trim(e.val()), d=/(\d{1,2})[\/\-\.](\d{1,2})[\/\-\.](\d{4})(\s(\d{1,2})[:\.](\d{1,2}))?/.exec(v), h=0, m=0; if(d){ if(typeof d[ 5 ]!='undefined') h=d[ 5 ]; if(typeof d[ 6 ]!='undefined') m=d[ 6 ]; var date=(this.dformat=='mm/dd/yyyy') ? new Date(d[ 3 ],(d[ 1 ] * 1 - 1), d[ 2 ], h, m, 0, 0):new Date(d[ 3 ],(d[ 2 ] * 1 - 1), d[ 1 ], h, m, 0, 0); if(this.showTimepicker){ return date.valueOf() / 86400000; }else{ return Math.ceil(date.valueOf() / 86400000); }} } return 0; }, setVal:function(v){ try { $('[name="'+this.name+'"]').val(v); if(v.length){ v=v.replace(/\s+/g, ' ').split(' '); this.defaultDate=v[ 0 ]; this.setDefaultDate(); if(v.length==2){ this.defaultTime=v[ 1 ]; this.setDefaultTime(); }} }catch(err){}} } ); $.fbuilder.controls[ 'ftextarea' ]=function(){}; $.extend($.fbuilder.controls[ 'ftextarea' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Untitled", ftype:"ftextarea", predefined:"", predefinedClick:false, required:false, size:"medium", minlength:"", maxlength:"", rows:4, show:function(){ return '
'+this.userhelp+'
'; }, val:function(){ var e=$('[id="' + this.name + '"]:not(.ignore)'), v=''; if(e.length){ v=e.val(); } return v; }} ); $.fbuilder.controls[ 'fcheck' ]=function(){}; $.extend($.fbuilder.controls[ 'fcheck' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Check All That Apply", ftype:"fcheck", layout:"one_column", required:false, showDep:false, show:function(){ this.choicesVal=((typeof(this.choicesVal)!="undefined"&&this.choicesVal!==null)?this.choicesVal:this.choices.slice(0)); var str=""; if(!(typeof(this.choicesDep)!="undefined"&&this.choicesDep!==null)){ this.choicesDep=new Array(); for (var i=0;i'; } return '
'+str+''+this.userhelp+'
'; }, showHideDep:function(toShow, toHide){ var item=$('#'+this.name+'.depItem'), form_identifier=this.form_identifier; try { if(item.length){ var parent=item.closest('.fields'); parent.find('.field').each(function(){ var item=$(this); if(item.attr('dep')&&item.attr('dep')!=''){ var d=item.attr('dep').split(','); for(i=0; i'; } return '
'+str+''+this.userhelp+'
'; }, showHideDep:function(toShow, toHide){ var item=$('#'+this.name+'.depItem'), form_identifier=this.form_identifier; try { if(item.length){ var parent=item.closest('.fields'); parent.find('.field').each(function(){ var item=$(this); if(item.attr('dep')&&item.attr('dep')!=''){ var d=item.attr('dep').split(','); for(i=0; i'+l[i]+''; } return '
'+this.userhelp+'
'; }, showHideDep:function(toShow, toHide){ var item=$('#'+this.name), form_identifier=this.form_identifier; try { if(item.find('.depItem').length){ var id=item.attr('id'); item.find('.depItem').each(function(){ var item=$(this); if(item.attr('dep')&&item.attr('dep')!=''){ var d=item.attr('dep').split(','); for(i=0; i
'+this.userhelp+'
'; }, after_show:function(){ $.validator.addMethod("upload_size", function(value, element,params){ return this.optional(element)||(element.files[0].size/1024 < params); }); }} ); $.fbuilder.controls[ 'fpassword' ]=function(){}; $.extend($.fbuilder.controls[ 'fpassword' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Untitled", ftype:"fpassword", predefined:"", predefinedClick:false, required:false, size:"medium", minlength:"", maxlength:"", equalTo:"", show:function(){ return '
'+this.userhelp+'
'; }, val:function(){ var e=$('[id="' + this.name + '"]:not(.ignore)'); if(e.length) return $.fbuilder.parseValStr(e.val()); return ''; }} ); $.fbuilder.controls[ 'fPhone' ]=function(){}; $.extend($.fbuilder.controls[ 'fPhone' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Phone", ftype:"fPhone", required:false, readonly:false, dformat:"### ### ####", predefined:"888 888 8888", predefinedClick:true, show:function(){ var me=this, str="", tmp=this.dformat.split(' '), tmpv=this.predefined.split(' '), attr=(typeof this.predefinedClick!='undefined'&&this.predefinedClick) ? 'placeholder':'value'; for (var i=0;i
'+$.trim(tmp[i])+'
'; }} return '
'+str+''+this.userhelp+'
'; }, after_show: function(){ var me=this, tmp=me.dformat.split(' '); if(!('phone' in $.validator.methods)) $.validator.addMethod("phone", function(value, element){ if(this.optional(element)) return true; else return /^\+{0,1}\d*$/.test(value); }); for (var i=0, h=tmp.length; i < h; i++){ $('#'+me.name+'_'+i).bind('change', function(){ var v=''; for(var i=0; i < tmp.length; i++){ v +=$('#'+me.name+'_'+i).val(); } $('#'+me.name).val(v).change(); }); if(i+1 < h){ $('#'+me.name+'_'+i).bind('keyup', { 'next': i+1 }, function(evt){ var e=$(this); if(e.val().length==e.attr('maxlength')){ e.change(); $('#'+me.name+'_'+evt.data.next).focus(); }}); }} }, val:function(raw){ raw=raw||false; var e=$('[id="' + this.name + '"]:not(.ignore)'); if(e.length) return $.fbuilder.parseValStr(e.val(), raw); return 0; }, setVal:function(v){ $('[name="'+this.name+'"]').val(v); v=$.trim(v).replace(/[^\d]/g, ' ').split(' '); for(var i in v) $('[id="' + this.name + '_' + i + '"]').val(v[ i ]); }} ); $.fbuilder.controls[ 'fCommentArea' ]=function(){}; $.extend($.fbuilder.controls[ 'fCommentArea' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Comments here", ftype:"fCommentArea", userhelp:"A description of the section goes here.", show:function(){ return '
'+this.userhelp+'
'; }} ); $.fbuilder.controls[ 'fhidden' ]=function(){}; $.extend($.fbuilder.controls[ 'fhidden' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fhidden", title:"", predefined:"", show:function(){ return '
'; }} ); $.fbuilder.controls[ 'fSectionBreak' ]=function(){}; $.extend($.fbuilder.controls[ 'fSectionBreak' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Section Break", ftype:"fSectionBreak", userhelp:"A description of the section goes here.", show:function(){ return '
'+this.userhelp+'
'; }} ); $.fbuilder.controls[ 'fPageBreak' ]=function(){}; $.extend($.fbuilder.controls[ 'fPageBreak' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Page Break", ftype:"fPageBreak", show:function(){ return '
'+this.userhelp+'
'; }} ); $.fbuilder.controls[ 'fsummary' ]=function(){}; $.extend($.fbuilder.controls[ 'fsummary' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Summary", ftype:"fsummary", fields:"", titleClassname:"summary-field-title", valueClassname:"summary-field-value", fieldsArray:[], show:function(){ var me=this, p=$.trim(me.fields.replace(/\,+/g, ',')).split(','), l=p.length; if(l){ var str='
'+(( !/^\s*$/.test(me.title)) ? '

'+me.title+'

': '')+'
'; for(var i=0; i < l; i++){ if(!/^\s*$/.test(p[ i ])){ p[ i ]=$.trim(p[ i ]); str +='
'; }} str +='
'; return str; }}, after_show: function(){ var me=this, p=$.trim(me.fields.replace(/\,+/g, ',')).split(','), l=p.length; if(l){ for(var i=0; i < l; i++){ if(!/^\s*$/.test(p[ i ])){ p[ i ]=$.trim(p[ i ]); me.fieldsArray.push(p[ i ] + me.form_identifier); $(document).on('change', '#' + p[ i ] + me.form_identifier, function(){ me.update(); }); }} $(document).on('showHideDepEvent', function(evt, form_identifier){ me.update(); }); $('#cp_calculatedfieldsf_pform'+me.form_identifier).bind('reset', function(){ setTimeout(function(){ me.update(); }, 10); }); }}, update:function(){ for(var j=0, k=this.fieldsArray.length; j < k; j++){ var i=this.fieldsArray[ j ], e=$('[id="' + i + '"]'), tt=$('[ref="' + i + '"]'); if(e.length&&tt.length){ var t=$('#' + i).closest('.fields').find('label[for="'+i+'"]').text(), v=[]; e.each(function(){ var e=$(this); if(/(checkbox|radio)/i.test(e.attr('type'))&&!e.is(':checked')){ return; } else if(e[0].tagName=='SELECT'){ v.push($(e[0].options[ e[0].selectedIndex ]).attr('vt')); }else{ if(e.attr('vt')){ v.push(e.attr('vt')); } else if(e.attr('summary')){ v.push($('#' + i).closest('.fields').find('.'+e.attr('summary')+i).html()); }else{ v.push(e.val()); }} } ); if(t.substring(t.length-1)=='*') t=t.substring(0, t.length-1); if(t.substring(t.length-1)==':') t=t.substring(0, t.length-1); tt.find('.cff-summary-title').html(( /^\s*$/.test(t)) ? '':t); tt.find('.cff-summary-value').html(v.join(', ')); if(e.hasClass('ignore')){ tt.hide(); }else{ tt.show(); }} }} }); $.fbuilder.controls[ 'datasource' ]=function(){}; $.fbuilder.controls[ 'datasource' ].prototype={ isDataSource:true, active:'', list:{ 'database':{ databaseData: '', queryData:{ active: 'structure', query: '', value: '', text: '', table: '', where: '', orderby: '' }, getData:function(callback, p){ var url=document.location.href, data=$.extend({}, this.queryData); if(data.active=='structure'){ data.where=p.replaceVariables(data.where); }else{ data.query=p.replaceVariables(data.query); } $.ajax({ dataType:'json', url:url, cache:false, data:$.extend({ cffaction: 'get_data_from_database' }, this.databaseData, data), success:function(data){ callback(data); }} ); }}, 'csv':{ csvData:{ text:0, value:0, fields:[], rows:[] }, getData:function(callback){ var obj={ data:[] }; for(var i in this.csvData.rows){ var text=this.csvData.text, value=this.csvData.value; if(typeof this.csvData.rows[ i ].length=='undefined'){ text=this.csvData.fields[ text ]; value=this.csvData.fields[ value ]; } obj.data.push({ text: this.csvData.rows[ i ][ text ], value:this.csvData.rows[ i ][ value ] }); } callback(obj); }}, 'posttype':{ posttypeData:{ posttype:'', value:'', text:'', last:'', id:'' }, getData:function(callback, p){ var url=document.location.href, data=$.extend({}, this.posttypeData); if(!/^\s*$/.test(data.id)){ data.id=p.replaceVariables(data.id); } $.ajax({ dataType:'json', url:url, cache:false, data:$.extend({ cffaction: 'get_posts' }, data), success:function(data){ callback(data); }} ); }}, 'taxonomy':{ taxonomyData:{ taxonomy:'', value:'', text:'', id:'', slug:'' }, getData:function(callback, p){ var url=document.location.href, data=$.extend({}, this.taxonomyData); if(!/^\s*$/.test(data.id)){ data.id=p.replaceVariables(data.id); } if(!/^\s*$/.test(data.slug)){ data.slug=p.replaceVariables(data.slug); } $.ajax({ dataType:'json', url:url, cache:false, data:$.extend({ cffaction: 'get_taxonomies' }, data), success:function(data){ callback(data); }} ); }}, 'user':{ userData:{ logged:false, text:'', value:'', id:'', login:'' }, getData:function(callback, p){ var url=document.location.href, data=$.extend({}, this.userData); if(!data.logged){ if(!/^\s*$/.test(data.id)){ data.id=p.replaceVariables(data.id); } if(!/^\s*$/.test(data.login)){ data.login=p.replaceVariables(data.login); }} $.ajax({ dataType:'json', url:url, cache:false, data:$.extend({ cffaction: 'get_users' }, data), success:function(data){ callback(data); }} ); }} }, getData:function(callback){ this.list[ this.active ].getData(callback, this); }, replaceVariables:function(str){ var _match, tmpArr=[]; while(_match=/<[%](fieldname\d+)[%]>/.exec(str)){ var me=this, e=_match[ 1 ]+this.form_identifier, f=$.fbuilder[ 'forms' ][ this.form_identifier ].getItem(e); if(( typeof this.hasBeenPutRelationHandles=='undefined'||!this.hasBeenPutRelationHandles)&&$.inArray(_match[ 1 ], tmpArr)==-1){ $(document).on('change', '#'+e, function(){ me.after_show(); } ); tmpArr.push(_match[ 1 ]); } if(f){ str=str.replace(_match[ 0 ], f.val()); }} this.hasBeenPutRelationHandles=true; return str; }}; $.fbuilder.controls[ 'ftextds' ]=function(){}; $.extend($.fbuilder.controls[ 'ftextds' ].prototype, $.fbuilder.controls[ 'ftext' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"ftextds", show:function(){ return $.fbuilder.controls[ 'ftext' ].prototype.show.call(this); }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ if(data.data.length){ $('#' + me.name).val(data.data[ 0 ][ 'value' ]).change(); }} } ); }});$.fbuilder.controls[ 'femailds' ]=function(){}; $.extend($.fbuilder.controls[ 'femailds' ].prototype, $.fbuilder.controls[ 'femail' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"femailds", show:function(){ return $.fbuilder.controls[ 'femail' ].prototype.show.call(this); }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ if(data.data.length){ $('#' + me.name).val(data.data[ 0 ][ 'value' ]).change(); }} } ); }});$.fbuilder.controls[ 'ftextareads' ]=function(){}; $.extend($.fbuilder.controls[ 'ftextareads' ].prototype, $.fbuilder.controls[ 'ftextarea' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"ftextareads", show:function(){ return $.fbuilder.controls[ 'ftextarea' ].prototype.show.call(this); }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ if(data.data.length){ $('#' + me.name).val(data.data[ 0 ][ 'value' ]).change(); }} } ); }});$.fbuilder.controls[ 'fcheckds' ]=function(){}; $.extend($.fbuilder.controls[ 'fcheckds' ].prototype, $.fbuilder.controls[ 'fcheck' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fdropdownds", show:function(){ return '
'+this.userhelp+'
'; }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ var str=''; for(var i=0, h=data.data.length; i < h; i++){ var e=data.data[ i ]; str +='
'; } $('#field' + me.form_identifier + '-' + me.index + ' .dfield').html(str).change(); }} ); }});$.fbuilder.controls[ 'fradiods' ]=function(){}; $.extend($.fbuilder.controls[ 'fradiods' ].prototype, $.fbuilder.controls[ 'fradio' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fradiods", show:function(){ return '
'+this.userhelp+'
'; }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ var str=''; for(var i=0, h=data.data.length; i < h; i++){ var e=data.data[ i ]; str +='
'; } $('#field' + me.form_identifier + '-' + me.index + ' .dfield').html(str).change(); }} ); }} ); $.fbuilder.controls[ 'fPhoneds' ]=function(){}; $.extend($.fbuilder.controls[ 'fPhoneds' ].prototype, $.fbuilder.controls[ 'fPhone' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fPhoneds", show:function(){ return $.fbuilder.controls[ 'fPhone' ].prototype.show.call(this); }, after_show:function(){ var me=this; $.fbuilder.controls[ 'fPhone' ].prototype.after_show.call(me); $.fbuilder.controls[ 'datasource' ].prototype.getData.call(me, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ if(data.data.length){ var v=data.data[ 0 ].value, p=$.trim(me.dformat.replace(/[^\s#]/g, '').replace(/\s+/g, ' ')).split(' '), h=p.length, r='', e; for(var i=0; i < h; i++){ r +='(.{' + p[ i ].length + '})'; } v=v.replace(/\s+/, ''); e=(new RegExp(r)).exec(v); if(e){ for(var i=0; i < h; i++){ $('#' + me.name + '_' + i).val(e[ i+1 ]).change(); }} }} } ); }} ); $.fbuilder.controls[ 'fdropdownds' ]=function(){}; $.extend($.fbuilder.controls[ 'fdropdownds' ].prototype, $.fbuilder.controls[ 'fdropdown' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fdropdownds", show:function(){ this.choices=[]; return $.fbuilder.controls[ 'fdropdown' ].prototype.show.call(this); }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ var str='', t, v; for(var i=0, h=data.data.length; i < h; i++){ v=(( typeof data.data[ i ][ 'value' ]!='undefined') ? data.data[ i ][ 'value' ]:''); t=(( typeof data.data[ i ][ 'text' ]!='undefined') ? data.data[ i ][ 'text' ]:v); str +=''; } $('#' + me.name).html(str).change(); }} ); }});$.fbuilder.controls[ 'fhiddends' ]=function(){}; $.extend($.fbuilder.controls[ 'fhiddends' ].prototype, $.fbuilder.controls[ 'fhidden' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fhiddends", show:function(){ return $.fbuilder.controls[ 'fhidden' ].prototype.show.call(this); }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ if(typeof data.error!='undefined'){ alert(data.error); }else{ if(data.data.length){ $('#' + me.name).val(data.data[ 0 ][ 'value' ]).change(); }} } ); }} ); $.fbuilder.controls[ 'fcontainer' ]=function(){}; $.fbuilder.controls[ 'fcontainer' ].prototype={ fields:[], columns:1, after_show: function(){ var e=$('#'+this.name), f; for(var i=0, h=this.fields.length; i < h; i++){ f=$('#'+this.fields[ i ]+this.form_identifier).closest('.fields').detach(); if(this.columns > 1){ f.addClass('column'+this.columns); if(i%this.columns==0) f.css('clear', 'left'); } f.appendTo(e); }}, showHideDep:function(toShow, toHide){ var hide=($.inArray(this.name, toHide)!=-1), index; for(var i=0, h=this.fields; i < h; i++){ if($.inArray(this.fields[ i ]+this.form_identifier, toHide)==-1){ toHide.push(this.fields[ i ]+this.form_identifier); index=$.inArray(d[ i ], toShow); if(index!=-1){ toShow.splice(index, 1); } $('#' + this.fields[ i ]+this.form_identifier).closest('.fields') .find('.field') .each(function(){ $(this).addClass('ignore'); }); }} }}; $.fbuilder.controls[ 'ffieldset' ]=function(){}; $.extend($.fbuilder.controls[ 'ffieldset' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Untitled", ftype:"ffieldset", fields:[], columns:1, show:function(){ return '
'+(( !/^\s*$/.test(this.title)) ? ''+this.title+'':'')+'
'; }, after_show: function(){ $.fbuilder.controls[ 'fcontainer' ].prototype.after_show.call(this); }, showHideDep:function(toShow, toHide){ $.fbuilder.controls[ 'fcontainer' ].prototype.showHideDep.call(this, toShow, toHide); }} ); $.fbuilder.controls[ 'fdiv' ]=function(){}; $.extend($.fbuilder.controls[ 'fdiv' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fdiv", fields:[], columns:1, show:function(){ return '
'; }, after_show: function(){ $.fbuilder.controls[ 'fcontainer' ].prototype.after_show.call(this); }, showHideDep:function(toShow, toHide){ $.fbuilder.controls[ 'fcontainer' ].prototype.showHideDep.call(this, toShow, toHide); }} ); $.fbuilder.controls[ 'fMedia' ]=function(){}; $.extend($.fbuilder.controls[ 'fMedia' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fMedia", sMediaType:"image", data:{ image:{ sWidth:"", sHeight:"", sSrc:"", sAlt:"", sLink:"", sTarget:"", sFigcaption: "" }, audio:{ sWidth:"", sSrc:"", sSrcAlt:"", sControls:1, sLoop:0, sAutoplay:0, sMuted:0, sPreload: "auto", sFallback: "", sFigcaption: "" }, video:{ sWidth:"", sHeight:"", sSrc:"", sSrcAlt:"", sPoster:"", sControls:1, sLoop:0, sAutoplay:0, sMuted:0, sPreload: "auto", sFallback: "", sFigcaption: "" }}, _show_image: function(){ var d=this.data.image, esc=$.fbuilder.htmlEncode, a=[], l=[], r=''; if($.trim(d.sWidth)) a.push('width="'+esc(d.sWidth)+'"'); if($.trim(d.sHeight)) a.push('height="'+esc(d.sHeight)+'"'); if($.trim(d.sSrc)) a.push('src="'+esc(d.sSrc)+'"'); if($.trim(d.sAlt)) a.push('alt="'+esc(d.sAlt)+'"'); if($.trim(d.sLink)){ l.push('href="'+esc(d.sLink)+'"'); if($.trim(d.sTarget)) l.push('target="'+esc(d.sTarget)+'"'); r=''; }else{ r=''; } return r; }, _show_audio_video: function(d, isV){ var esc=$.fbuilder.htmlEncode, a=[], t=(isV) ? 'video':'audio' ; if($.trim(d.sWidth)) a.push('width="'+esc(d.sWidth)+'"'); if(isV&&$.trim(d.sHeight)) a.push('height="'+esc(d.sHeight)+'"'); if(isV&&$.trim(d.sPoster)) a.push('poster="'+esc(d.sPoster)+'"'); if($.trim(d.sSrc)) a.push('src="'+esc(d.sSrc)+'"'); if(d.sAutoplay) a.push('autoplay'); if(d.sControls) a.push('controls'); if(d.sLoop) a.push('loop'); if(d.sMuted) a.push('muted'); a.push('preload="'+esc(d.sPreload)+'"'); return '<'+t+' '+a.join(' ')+'>'+(( $.trim(d.sSrcAlt)) ? '':'')+'

'+d.sFallback+'

'; }, _show_audio: function(){ return this._show_audio_video(this.data.audio, false); }, _show_video: function(){ return this._show_audio_video(this.data.video, true); }, show:function(){ return '
'+this[ '_show_'+this.sMediaType]()+'
'+this.data[ this.sMediaType].sFigcaption+'
'; }} ); $.fbuilder.controls[ 'fButton' ]=function(){}; $.extend($.fbuilder.controls[ 'fButton' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fButton", sType:"button", sValue:"button", sOnclick:"", userhelp:"A description of the section goes here.", show:function(){ var esc=function(v){ v=v.replace(/</g, '&').replace(/"/g, """).replace(/\n+/g, ' '); return v;}, type=this.sType, clss=''; if(this.sType=='calculate'){ type='button'; clss='calculate-button'; } else if(this.sType=='reset'){ clss='reset-button'; } return '
'+this.userhelp+'
'; }, after_show:function(){ $('#'+this.name).click(function(){ var e=$(this); if(e.hasClass('calculate-button')){ var suffix=e.attr('id').match(/_\d+$/)[0], items=$.fbuilder[ 'forms' ][ suffix ].getItems(); $.fbuilder[ 'calculator' ].defaultCalc('#'+e.closest('form').attr('id')); for(var i=0, h=items.length; i < h; i++){ if(items[i].ftype=='fsummary'){ items[i].update(); }} } if(e.hasClass('reset-button')){ setTimeout( function(){ var identifier=e.closest('form').attr('id').replace(/cp_calculatedfieldsf_pform/, ''); $.fbuilder[ 'showHideDep' ]({ 'formIdentifier':identifier }); var page=parseInt(e.closest('.pbreak').attr('page')); if(page){ $("#fieldlist"+identifier+" .pbreak").css("display","none"); $("#fieldlist"+identifier+" .pbreak").find(".field").addClass("ignorepb"); $("#fieldlist"+identifier+" .pb0").css("display","block"); if($("#fieldlist"+identifier+" .pb0").find(".field").length>0){ $("#fieldlist"+identifier+" .pb0").find(".field").removeClass("ignorepb"); try { $("#fieldlist"+identifier+" .pb0").find(".field")[0].focus(); } catch(e){}} }}, 50 ); }} ); }} ); $.fbuilder.controls[ 'fnumberds' ]=function(){}; $.extend($.fbuilder.controls[ 'fnumberds' ].prototype, $.fbuilder.controls[ 'fnumber' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fnumberds", show:function(){ return $.fbuilder.controls[ 'fnumber' ].prototype.show.call(this); }, after_show:function(){ var me=this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call(this, function(data){ var v=''; if(typeof data.error!='undefined'){ alert(data.error); }else{ if(data.data.length){ v=data.data[ 0 ][ 'value' ]; }} $('#' + me.name).val(v).change(); } ); }});$.fbuilder.controls[ 'fhtml' ]=function(){}; $.extend($.fbuilder.controls[ 'fhtml' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fhtml", fcontent:"", show:function(){ return '
'+$('
').html(this.fcontent).html()+'
'; }} );$.fbuilder.controls[ 'fapp' ]=function(){}; $.extend($.fbuilder.controls[ 'fapp' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Number", ftype:"fapp", services:new Array({name:"Service 1",price:1,capacity:1,duration:60,pb:0,pa:0,ohindex:0}), openhours:new Array(), allOH:new Array({name:"Default",openhours:new Array({type:"all",d:"",h1:8,m1:0,h2:17,m2:0})}), usedSlots:new Array(), dateFormat:"mm/dd/yy", showDropdown:false, showTotalCost:false, showTotalCostFormat:"$ {0}", showEndTime:false, usedSlotsCheckbox:false, avoidOverlaping:true, emptySelectCheckbox:false, emptySelect:"-- Please select service --", dropdownRange:"-10:+10", working_dates:[true,true,true,true,true,true,true], numberOfMonths:1, maxNumberOfApp:0, firstDay:0, minDate:"0", maxDate:"", defaultDate:"", invalidDates:"", required:true, bSlotsCheckbox: true, bSlots:30, militaryTime:1, cacheArr:new Array(), getD:new Date(), formId:0, getMinDate:"", arr:new Array(), allUsedSlots:new Array(), invalidDatesByService:new Array(), service_selected:0, quantity_selected:1, tz:0, loadOK:false, ignoreUsedSlots:false, initialapp:"", initialID:0, pctByDay:new Array(), htmlUsedSlots:new Array(), extras:0, sub_cost:0, getCompatSlots:function(d){ var data=new Array(); var find=false; for (var i=0;i 0) ind--; return ind; }, show:function(){ return '
'+this.userhelp+'
'; }, getSpecialDays:function(){ var me=this; var a=new Array(); if(!me.emptySelectCheckbox||(me.emptySelectCheckbox&&$(".fieldCalendarService"+me.name+" select option:selected").index() > 0)){ var ohindex=me.services[me.normalizeSelectIndex($(".fieldCalendarService"+me.name+" select option:selected").index())].ohindex; for (var i=0;i=arr[i].t2) arr[i].t2 +=24 * 60; } me.usedSlots[d]=me.usedSlots[d]||[]; if(me.ignoreUsedSlots) var data2=$.merge(data1.slice(0),[]); else var data2=$.merge(data1.slice(0),me.usedSlots[d]); for (var i=0;idata[i].t2) data[i].t2 +=24 * 60; for (var i=0;icapacity_service||(data[i].service.length==0||(data[i].service.length&&data[i].service[0]!=me.service_selected))) || (!me.avoidOverlaping&&(data[i].quantity+me.quantity_selected>capacity_service&&(typeof data[i].serviceindex==='undefined'||data[i].serviceindex==me.service_selected)))){ for (var j=0;j arr[j].t1)&&(data[i].t1 < arr[j].t2)&&(data[i].t2 > arr[j].t1)&&(data[i].t2 < arr[j].t2)){ var v1={t1:arr[j].t1, t2:data[i].t1, h1:arr[j].h1, h2:data[i].h1, m1:arr[j].m1, m2:data[i].m1}; var v2={t1:data[i].t2, t2:arr[j].t2, h1:data[i].h2, h2:arr[j].h2, m1:data[i].m2, m2:arr[j].m2}; arr.splice(j, 1, v1, v2); } else if((data[i].t1 > arr[j].t1)&&(data[i].t1 < arr[j].t2)){ arr[j].t2=data[i].t1; arr[j].h2=data[i].h1; arr[j].m2=data[i].m1; } else if((data[i].t2 > arr[j].t1)&&(data[i].t2 < arr[j].t2)){ arr[j].t1=data[i].t2; arr[j].h1=data[i].h2; arr[j].m1=data[i].m2; } else if((data[i].t1 <=arr[j].t1)&&(data[i].t2 >=arr[j].t2)){ arr.splice(j, 1); }} }} for (var i=0;i=0;i--){ if($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+arr[i].t2*60*1000 <=currenttime) arr.splice(i, 1); else if($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+arr[i].t1*60*1000 <=currenttime){ var st=arr[i].t1 + me.duration; while ($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime() + st*60*1000 <=currenttime) st +=me.duration; var m1=st % 60; var h1=(st - m1)/60; arr[i].t1=st; arr[i].h1=h1; arr[i].m1=m1; }} } for (var i=arr.length-1;i>=0;i--) if(arr[i].t1+me.duration > arr[i].t2||arr[i].t1 > 24*60) arr.splice(i, 1); return arr; }, formattime: function(t,mt) { if(t<0) t+=(24*60); t=t % (24*60); var h=Math.floor(t/60); var m=t%60; var suffix=""; if(mt==0){ if(h>12){ h=h-12; suffix=" PM"; } else if(h==12) suffix=" PM"; else suffix=" AM"; } return (((h<10)?((mt==2)?"0":""):"")+h+":"+(m<10?"0":"")+m)+suffix; }, formatString: function(obj,showdate,tz){ var me=this; tz=tz * 60; if(typeof obj.st==='undefined') obj.st=obj.h1*60+obj.m1*1; if(typeof obj.et==='undefined') obj.et=obj.h2*60+obj.m2*1; var str=""; if(showdate) str +=$.datepicker.formatDate(me.dateFormat, $.datepicker.parseDate("yy-mm-dd", obj.d))+" "; str +=me.formattime(obj.st+tz,me.militaryTime)+(me.showEndTime?("-"+me.formattime(obj.et+tz,me.militaryTime)):""); return str; }, getCurrentSlots: function(arr,d){ var me=this; var duration=me.duration; var html=""; var htmlSlots=new Array(); var pb=0; var pa=0; var capacity_service=me.services[me.service_selected].capacity; if(true){ var compactUsedSlots=me.getCompatSlots(me.htmlUsedSlots[d]) for (var i=0;i=capacity_service) compactUsedSlots[i].html='
'+me.formatString(compactUsedSlots[i],false,me.tz)+''+((typeof compactUsedSlots[i].e!=='undefined')?"
"+compactUsedSlots[i].e+"
":"")+'
'; if(me.usedSlotsCheckbox) htmlSlots[htmlSlots.length]=compactUsedSlots[i]; }} } if((typeof specialPadding==='undefined')){ pb=me.pb; pa=me.pa; } for (var i=0;i=et) et +=24 * 60; while (st + duration + me.pa <=et&&st<24 * 60){ html=""; htmlSlots[htmlSlots.length]={st:st,html:html,t:$.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+st*60*1000}; st +=me.bduration + pa + pb; }} htmlSlots.sort(function(a, b){ if((typeof cp_hourbk_cmpublic!=='undefined')&&(a.t==b.t)){ if((typeof a.quantity!=='undefined')&&(typeof b.quantity==='undefined')){ b.html=b.html.replace("ahbslotavailabilityP",(capacity_service - a.quantity)); b.quantity=a.quantity; } else if((typeof b.quantity!=='undefined')&&(typeof a.quantity==='undefined')){ a.html=a.html.replace("ahbslotavailabilityP",(capacity_service - b.quantity)); a.quantity=b.quantity; }} return a.t - b.t }); return htmlSlots; }, getAvailableSlots: function(d){ var me=this; function setHtmlUsedSlots(d,st,et){ st=st * 60; et=et * 60; var htmlSlots=new Array(); if(me.usedSlotsCheckbox){ me.cacheArr[d]=me.cacheArr[d]||[]; for (var i=0;i=me.cacheArr[d][i].h2*60+me.cacheArr[d][i].m2) htmlSlots[htmlSlots.length]=jQuery.extend({}, me.cacheArr[d][i]); for (var i=0;me.usedSlots[d]&&i=me.usedSlots[d][i].h2*60+me.usedSlots[d][i].m2) htmlSlots[htmlSlots.length]=jQuery.extend({}, me.usedSlots[d][i]); }} return htmlSlots; } var day=$.datepicker.parseDate("yy-mm-dd", d); if(this.tz==0){ me.htmlUsedSlots[d]=setHtmlUsedSlots(d,0,24); var arr=this.getAvailablePartialSlots(d,[{h1:0,m1:0,h2:0,m2:0}]); } else if(this.tz > 0){ day.setDate(day.getDate() - 1); var d1=$.datepicker.formatDate("yy-mm-dd",day); var arr=$.merge(this.getAvailablePartialSlots(d1,[{h1:0,m1:0,h2:24-this.tz,m2:0}]),this.getAvailablePartialSlots(d,[{h1:24-this.tz,m1:0,h2:24,m2:0}])); me.htmlUsedSlots[d]=$.merge(setHtmlUsedSlots(d1,24-this.tz,24), setHtmlUsedSlots(d,0,24-this.tz)); }else{ day.setDate(day.getDate() + 1); var d1=$.datepicker.formatDate("yy-mm-dd",day); var arr=$.merge(this.getAvailablePartialSlots(d,[{h1:0,m1:0,h2:this.tz*-1,m2:0}]),this.getAvailablePartialSlots(d1,[{h1:this.tz*-1,m1:0,h2:24,m2:0}])); me.htmlUsedSlots[d]=$.merge(setHtmlUsedSlots(d1,this.tz*-1,24), setHtmlUsedSlots(d,0,this.tz*-1)); } var c="s"+me.service_selected+"q"+me.quantity_selected; if(arr.length==0){ me.invalidDatesByService[c]=me.invalidDatesByService[c]||[]; if($.inArray(d, me.invalidDatesByService[c])==-1) me.invalidDatesByService[c][me.invalidDatesByService[c].length]=d; } return arr; }, after_show:function(){ function closeOtherDatepicker(){ $('#ui-datepicker-div').css("display","none"); } setTimeout(closeOtherDatepicker,100); if(typeof cp_hourbk_timezone!=='undefined'){ var gmt=(parseInt(cp_hourbk_timezone)); var local=(new Date().getTimezoneOffset() * -1)/60; this.tz=local - gmt; } var me=this, e=$('#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name), d=$('#field' + me.form_identifier + '-' + me.index + ' .fieldCalendarService'+me.name), str="", op=""; e.addClass("notranslate") if(me.openhours.length>0) { if(!me.openhours[0].name){ var obj={name:"Default",openhours:me.openhours.slice(0)}; me.openhours=new Array(); me.openhours[0]=obj; } me.allOH=new Array(); me.allOH=me.openhours.slice(0); me.openhours=new Array(); } var dd=""; if(me.initialapp!=""){ var s=me.initialapp.split(";"); var s2=""; for (var i=0;i 0)){ var arr=me.getAvailableSlots(day); if($.inArray(day, me.invalidDatesByService["s"+me.service_selected+"q"+me.quantity_selected]) > -1) c.push("nonworking","ui-datepicker-unselectable","ui-state-disabled","notavailslot"); if(typeof cp_hourbk_cmpublic!=='undefined'){ var used=0; var htmlSlots=me.getCurrentSlots(arr,day); var cclass=c.join(" "); var q=0; for (var i=0;i 0))) return; function getSlots(d){ var data1=me.cacheArr[d]; var duration=me.duration; me.bduration=me.duration; if(!me.bSlotsCheckbox) me.bduration=me.bSlots*1; var str=""; var arr=me.getAvailableSlots(d); var nextdateAvailable=$.datepicker.parseDate("yy-mm-dd", d); var c="s"+me.service_selected+"q"+me.quantity_selected; var s=$('#field' + me.form_identifier + '-' + me.index + ' .slotsCalendar'+me.name); var i=0; if((me.maxNumberOfApp==0||me.allUsedSlots.length0){ e.datepicker("setDate", nextdateAvailable); me.getD=nextdateAvailable; onChangeDateOrService($.datepicker.formatDate("yy-mm-dd", nextdateAvailable)); } else if(me.invalidDatesByService[c].length>=365){ if(me.getMinDate!=""&&me.getMinDate.getTime() < me.getD.getTime()){ e.datepicker("setDate", me.getMinDate); me.getD=me.getMinDate; me.invalidDatesByService[c]=new Array(); onChangeDateOrService($.datepicker.formatDate("yy-mm-dd", me.getD)); return; } e.datepicker("setDate", me.getMinDate); s.html("
"+cp_hourbk_nomore_label+"
"); } return; } var htmlSlots=me.getCurrentSlots(arr,d); var capacity_service=me.services[me.service_selected].capacity; for (var i=0;i0){ before=s.find(".slots").attr("d"); } s.html("
"+$.datepicker.formatDate(me.dateFormat, $.datepicker.parseDate("yy-mm-dd", d))+"
"+str+"
"); if(before!=""&&before!=d){ s.find(".slots span:first").hide().show(200); } var str1="",str2=""; me.allUsedSlots=me.allUsedSlots||[]; me.allUsedSlots.sort(function(a, b){ return ($.datepicker.parseDate("yy-mm-dd", a.d).getTime()+(a.h1*60+a.m1)*60*1000) - ($.datepicker.parseDate("yy-mm-dd", b.d).getTime()+(b.h1*60+b.m1)*60*1000)}); j=0; var total=0; for (var i=0;i"+me.formatString(me.allUsedSlots[i],true,me.tz)+""+me.services[me.allUsedSlots[i].serviceindex].name+""+((me.allUsedSlots[i].quantity>1)?"("+me.allUsedSlots[i].quantity+")":"")+"["+(cp_hourbk_cancel_label?cp_hourbk_cancel_label:'cancel')+"]"+(((typeof cp_hourbk_repeat!=='undefined')&&i==0)?showrepeat(me.name):"")+"
"; str2 +=((str2=="")?"":";")+me.allUsedSlots[i].d+" "+me.formattime(me.allUsedSlots[i].h1*60+me.allUsedSlots[i].m1*1,2)+"/"+me.formattime(me.allUsedSlots[i].h2*60+me.allUsedSlots[i].m2*1,2)+" "+me.allUsedSlots[i].serviceindex+" "+me.allUsedSlots[i].quantity; if(me.allUsedSlots[i].d==d) j++; } me.sub_cost=total; total=me.sub_cost + me.extras; total=total.toFixed(2); if(me.showTotalCost&&(str1!="")) str1 +='
'+cp_hourbk_cost_label+' '+me.showTotalCostFormat.replace("{0}", total)+'
'; $('#field' + me.form_identifier + '-' + me.index + ' .usedSlots'+me.name).html(str1); $('#field' + me.form_identifier + '-' + me.index + ' #'+me.name).val(str2); $('#field' + me.form_identifier + '-' + me.index + ' #tcost'+me.name).val(total); $('#field' + me.form_identifier + '-' + me.index + ' #'+me.name).change(); try { $("#fbuilder .slots div a").tooltip({ position: { my: "left top+10" }, open: function (event, ui){ $(this).tooltip("option", "content", $(this).parent().find(".ahbmoreinfo").html()); }, tooltipClass: "ahbtooltip" }); } catch (e){} $('#field' + me.form_identifier + '-' + me.index + ' .slots a').off("click").on("click", function(){ if($(this).parents("fieldset").hasClass("ahbgutenberg_editor")) return false; $("#field" + me.form_identifier + "-" + me.index + " div.cpefb_error").remove(); if($(this).parent().hasClass("htmlUsed")) return false; me.allUsedSlots=me.allUsedSlots||[]; if(me.maxNumberOfApp==0||me.allUsedSlots.length -1){ me.invalidDatesByService[c].splice($.inArray(d, me.invalidDatesByService[c]), 1); e.datepicker("setDate", me.getD); } onChangeDateOrService($.datepicker.formatDate('yy-mm-dd', me.getD)); return false; }); } getSlots(d); } if(typeof cpapphourbk_in_admin!=='undefined'){ me.minDate=""; me.maxDate=""; } if(!me.loadOK){ me.formId=$(".fieldCalendarService"+me.name).parents("form").find('input[type="hidden"][name$="_id"]').val(); $.ajax({ dataType:'json', type: "POST", url:document.location.href, cache:true, data:{ cp_app_action: 'get_slots', formid: me.formId, initialID: me.initialID, formfield: me.name.replace(me.form_identifier, "") }, success:function(data){ for (var i=0;i'+me.services[i].name+''; me.services[i].capacity=(parseInt(me.services[i].capacity)>0)?me.services[i].capacity:1; if(capacity'+ str ; var str2=""; for (var i=1;i<=me.services[0].capacity;i++) str2 +=''; d.html('

'); me.service_selected=me.normalizeSelectIndex($(".fieldCalendarService"+me.name+" select.ahbfield_service option:selected").index()); me.quantity_selected=parseInt($(".fieldCalendarService"+me.name+" select.ahbfield_quantity option:selected").val()); me.duration=$(".fieldCalendarService"+me.name+" select.ahbfield_service option:selected").val()*1; me.pa=me.services[me.service_selected].pa * 1||0; me.pb=me.services[me.service_selected].pb * 1||0; $(".fieldCalendarService"+me.name+" select.ahbfield_service").bind("change", function(){ me.duration=$(".fieldCalendarService"+me.name+" select.ahbfield_service option:selected").val()*1; me.service_selected=me.normalizeSelectIndex($(".fieldCalendarService"+me.name+" select.ahbfield_service option:selected").index()); me.pa=me.services[me.service_selected].pa * 1||0; me.pb=me.services[me.service_selected].pb * 1||0; me.cacheOpenHours=new Array(); me.special_days=me.getSpecialDays(); var str2=""; for (var i=1;i<=me.services[me.service_selected].capacity;i++) str2 +=''; $(".fieldCalendarService"+me.name+" select.ahbfield_quantity").html(str2); me.quantity_selected=parseInt($(".fieldCalendarService"+me.name+" select.ahbfield_quantity option:selected").val()); $('#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name).datepicker("option", "beforeShowDay", renderCalendarCallback); onChangeDateOrService($.datepicker.formatDate('yy-mm-dd', me.getD)); }); $(".fieldCalendarService"+me.name+" select.ahbfield_quantity").bind("change", function(){ me.quantity_selected=parseInt($(".fieldCalendarService"+me.name+" select.ahbfield_quantity option:selected").val()); $('#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name).datepicker("option", "beforeShowDay", renderCalendarCallback); onChangeDateOrService($.datepicker.formatDate('yy-mm-dd', me.getD)); }); $("#"+me.name).bind("change", function(){ if($(this).attr("reload")=="reload"){ $(this).attr("reload",""); onChangeDateOrService($.datepicker.formatDate('yy-mm-dd', me.getD)); }}); try{ me.special_days=me.getSpecialDays(); } catch (e){} var hrs=0; me.getMinDate=""; if(me.minDate!==""){ if(me.minDate.indexOf("h")!=-1){ if(me.minDate.indexOf(" ")!=-1){ var a=me.minDate.split(" "); var find=false; for (var i=0;(i -1) return false; if(me.working_dates[date.getDay()]==0) return false; return true; } var sum=0; for (var i=0;i0){ var nextdateAvailable=e.datepicker("getDate"); while (!DisableSpecificDates(nextdateAvailable)) nextdateAvailable.setDate(nextdateAvailable.getDate() + 1); e.datepicker("setDate", nextdateAvailable); me.getD=nextdateAvailable; function ifLoadOk(){ if(!me.loadOK) setTimeout(ifLoadOk,100); else { $('#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name).datepicker("option", "beforeShowDay", renderCalendarCallback); onChangeDateOrService($.datepicker.formatDate('yy-mm-dd', me.getD)); $('#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name).datepicker("option", "beforeShowDay", renderCalendarCallback); }} ifLoadOk(); } if(typeof cp_hourbk_preselect!=='undefined'&&cp_hourbk_preselect!=""){ cp_hourbk_preselect=cp_hourbk_preselect*1; $(".fieldCalendarService"+me.name+" select.ahbfield_service").children().removeAttr("selected"); if(me.emptySelectCheckbox) $(".fieldCalendarService"+me.name+" select.ahbfield_service").children().eq(cp_hourbk_preselect+1).attr('selected', 'selected').change(); else $(".fieldCalendarService"+me.name+" select.ahbfield_service").children().eq(cp_hourbk_preselect).attr('selected', 'selected').change(); } else if(me.initialapp!=""&&dd!="") onChangeDateOrService(dd); getExtras=function(){ var f=$('#field' + me.form_identifier + '-' + me.index).parents("form"); var v=0; var find=false; var e=f.find(".ahb_service").find(':checked:not(.ignore)'); if(e.length){ find=true; e.each(function(){ v +=this.value*1; }); } e=f.find(".ahb_service_per_slot").find(':checked:not(.ignore)'); me.allUsedSlots=me.allUsedSlots||[]; var s=me.allUsedSlots.length; if(e.length){ find=true; e.each(function(){ v +=this.value * s; }); } e=f.find(".ahb_service_per_quantity_selection").find(':checked:not(.ignore)'); var q=f.find(".sbquantity1").val() * 1 + f.find(".sbquantity2").val() * 1; if(e.length){ find=true; e.each(function(){ v +=this.value * q; }); } f.find('#'+me.name+'_services').val(v); if(find){ me.extras=v; var total=me.sub_cost + me.extras; total=total.toFixed(2); $('#field' + me.form_identifier + '-' + me.index).find(".totalCost .n").html(" " +me.showTotalCostFormat.replace("{0}",total)); $('#field' + me.form_identifier + '-' + me.index + ' #tcost'+me.name).val(total); }} $('#field' + me.form_identifier + '-' + me.index).parents("form").find(".ahb_service,.ahb_service_per_slot,.ahb_service_per_quantity_selection").on("click", function(){ getExtras(); }); $('#field' + me.form_identifier + '-' + me.index + ' #'+me.name).change(function(){ getExtras(); }); if(typeof cp_hourbk_overlapping_label!="undefined") $.extend($.validator.messages, {avoid_overlapping: $.validator.format(cp_hourbk_overlapping_label)}); if(!('avoid_overlapping' in $.validator.methods)){ function avoid_over_function(value, element){ var validator=this, previous=validator.previousValue(element); if(previous.old===value){ return previous.valid; } previous.old=value; validator.startRequest(element); var p=element.id.split('_'), _index=(p.length > 1) ? '_'+p[ 1 ]:'', me=( typeof $.fbuilder[ 'forms' ]!='undefined' && typeof $.fbuilder[ 'forms' ][ _index ]!='undefined' ) ? $.fbuilder[ 'forms' ][ _index ].getItem(p[ 0 ]+'_'+p[ 1 ]):null; if(me!=null){ $.ajax({ dataType:'json', type: "POST", url:document.location.href, data:{ cp_app_action: 'get_slots', formid: me.formId, initialID: me.initialID, formfield: me.name.replace(me.form_identifier, "") }, success: function(data){ var overlapping=false; var find=false; me.ignoreUsedSlots=true; me.cacheArr=new Array(); for (var i=0;i=t2) find=true; } overlapping = !find; } me.ignoreUsedSlots=false; var isValid = !overlapping; if(true===isValid){ var submitted=validator.formSubmitted; validator.prepareElement(element); validator.formSubmitted=submitted; validator.successList.push(element); delete validator.invalid[ element.name ]; validator.showErrors(); }else{ for (var i=0;i'+label+''; } else if(!/^\s*$/.test(me.message)){ label=''+label+''; dlg +='
'+me.message+'
' } return '
'+ '
'+ dlg+ '
'; }, after_show:function(){ $(document).on('click','.cff-open-dlg', function(){ var dlg=$(this).closest('.fields').find('.cff-dialog'), w=dlg.data('width'), h=dlg.data('height'); dlg.removeClass('hide'); if('undefined'==typeof w) w=Math.min($(this).closest('form').width(), $(window).width(), dlg.width()); if('undefined'==typeof h) h=Math.min($(this).closest('form').height(), $(window).height(), dlg.height()); dlg.data('width',w); dlg.data('height',h); dlg.css({'width': w+'px', 'height': h+'px', 'margin-top': (-1*h/2)+'px', 'margin-left': (-1*w/2)+'px'}); }); $(document).on('click','.cff-close-dlg', function(){$(this).closest('.cff-dialog').addClass('hide');}); }, val:function(){ var e=$('[id="'+this.name+'"]:checked:not(.ignore)'); if(e.length){ var t=$.fbuilder.parseValStr(e[0].value); if(!$.isNumeric(t)) t=t.replace(/^"/,'').replace(/"$/,''); } return (v) ? (($.isNumeric(v)) ? v:'"'+v+'"'):0; }} ); var fcount=1; var fcount_tags=1; var fnum="_"+fcount; while (20>fcount||eval("typeof cp_appbooking_fbuilder_config"+fnum+"!='undefined'")){ try { var cp_appbooking_fbuilder_config=eval("cp_appbooking_fbuilder_config"+fnum); while (20>fcount_tags&&!$("#fbuilder_"+fcount_tags).length) fcount_tags++; cp_appbooking_fbuilder_config=$.parseJSON(cp_appbooking_fbuilder_config.obj); cp_appbooking_fbuilder_config.identifier="_"+fcount_tags; var f=$("#fbuilder_"+fcount_tags).fbuilder(cp_appbooking_fbuilder_config); f.fBuild.loadData("form_structure_"+fcount_tags); $("#cp_appbooking_pform_"+fcount_tags).validate({ ignore:".ignore,.ignorepb", errorElement: "div", errorPlacement: function(e, element){ if(element.hasClass('group')) element=element.parent(); e.insertBefore(element); e.addClass('message'); e.css('position', 'absolute'); e.css('left',0); e.css('top',element.parent().outerHeight(true)); }}); } catch (e){} fcount++; fcount_tags++; fnum="_"+fcount; }})(fbuilderjQuery); });